package com.candy.control;

import com.candy.pojo.StudentInfo;
import com.candy.service.UserInfoManagerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getUserInfo")
public class UserInfoQueryServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //        设置字符集，处理中文乱码问题
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
//        调用业务逻辑处理层
        UserInfoManagerService usermanager=new UserInfoManagerService();
//        获取全部用户信息
        List<StudentInfo> ls=usermanager.getUserInfo();
//        将获取的用户信息，传给前端的页面中
        req.getSession().setAttribute("userinfoes",ls);
//        跳转到用户信息展示的jsp页面上
        req.getRequestDispatcher("WEB-INF/userManager/userInfo.jsp").forward(req,resp);


    }
}
